<template>
  <div class="scree">
    <div class="screeHeader">
      <a href="#" @click="$router.go(-1)">
        <img src="../../static/img/fanhui@2x.png" alt="">
      </a>
      <span>OPPO 潮牌</span>
    </div>
    <div class="screeMain">
      <mt-navbar v-model="selected">
        <mt-tab-item id="tab-container1">全部</mt-tab-item>
        <mt-tab-item id="tab-container2">潮牌挂脖腕带</mt-tab-item>
        <mt-tab-item id="tab-container3">水晶流苏</mt-tab-item>
        <mt-tab-item id="tab-container4">创意个性</mt-tab-item>
      </mt-navbar>
      <mt-tab-container v-model="selected" swipeable>
        <mt-tab-container-item id="tab-container1">
          <ul style="margin-top: 2px;margin-left: -40px">
            <li class="_screeList" v-for="(parts,index) in all" @click="open(parts.id)">
              <img v-lazy="parts.img" alt="图片">
              <h2>{{parts.title}}</h2>
              <p>{{parts.des}}</p>
              <div>￥{{parts.price}}</div>
            </li>
          </ul>
        </mt-tab-container-item>

        <mt-tab-container-item id="tab-container2">
          <ul style="margin-top: 2px;margin-left: -40px">
            <li class="_screeList" v-for="(parts,index) in belt" @click="open(parts.id)">
              <img v-lazy="parts.img" alt="图片">
              <h2>{{parts.title}}</h2>
              <p>{{parts.des}}</p>
              <div>￥{{parts.price}}</div>
            </li>
          </ul>
        </mt-tab-container-item>

        <mt-tab-container-item id="tab-container3">
          <ul style="margin-top: 2px;margin-left: -40px">
            <li class="_screeList" v-for="(parts,index) in stars" @click="open(parts.id)">
              <img v-lazy="parts.img" alt="图片">
              <h2>{{parts.title}}</h2>
              <p>{{parts.des}}</p>
              <div>￥{{parts.price}}</div>
            </li>
          </ul>
        </mt-tab-container-item>

        <mt-tab-container-item id="tab-container4">
          <ul style="margin-top: 2px;margin-left: -40px">
            <li class="_screeList" v-for="(parts,index) in special" @click="open(parts.id)">
              <img v-lazy="parts.img" alt="图片">
              <h2>{{parts.title}}</h2>
              <p>{{parts.des}}</p>
              <div>￥{{parts.price}}</div>
            </li>
          </ul>
        </mt-tab-container-item>
      </mt-tab-container>
    </div>
  </div>
</template>
<style>
  .scree {
    position: relative;
    width: 100%;
  }

  .screeHeader {
    width: 100%;
    z-index: 1;
    height: 1.3rem;
    line-height: 1.3rem;
    font-size: 15px;
    background: #3aab35;
    position: fixed;
    top: 0;
    left: 0;
    -webkit-box-shadow: 0 0 10px #cecece;
    box-shadow: 0 0 10px #cecece;
    text-align: center;
    color: #fff;
  }

  .screeHeader img {
    display: block;
    float: left;
    width: 9px;
    height: 16px;
    padding: 16px;
    color: black;
  }

  .screeMain {
    margin-top: 50px;
  }

  ._screeList {
    height: 7.8rem;
    background: white;
    float: left;
    box-sizing: border-box;
    width: 50%;
    border-right: 1px solid #F4F4F4;
    border-bottom: 1px solid #F4F4F4;
    float: left;
    margin-top: 1px;
    list-style: none;
  }

  ._screeList img {
    height: 3.6rem;
    width: 4rem;
    display: block;
    margin: auto;
    padding: 0.5rem;
  }

  ._screeList h2 {
    width: 90%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    font-size: .4rem;
    margin: auto;
  }

  ._screeList p {
    width: 3.8rem;
    margin: 0 auto;
    padding: 0;
    height: 2.6em;
    font-size: .22rem;
    line-height: 1.4;
    color: #000;
    text-align: center;
    word-break: break-all;
    overflow: hidden;
    padding-top: 0.2rem;
  }

  ._screeList div {
    text-align: center;
    color: red;
    padding-top: 0.6rem;
  }
</style>
<script>
  import {Navbar, TabItem} from 'mint-ui';

  export default {
    name: 'scree',
    data() {
      return {
        selected: "tab-container1",
        all: [],
        belt: [],
        stars: [],
        special: []
      }
    },
    mounted() {
      this.getAll();
      this.getbelt();
      this.getstars();
      this.getspecial()
    },
    methods: {
      getAll() {
        var _this = this;
        this.$http.get("/static/fashion.json").then(res => {
          if (res.status === 200) {
            _this.all = res.body.list
            // console.log(_this.all)
          }
        })
      },
      getbelt() {
        var _this = this;
        this.$http.get("/static/fashion.json").then(res => {
          // console.log(res)
          if (res.status === 200) {
            _this.belt = res.body.belt
            // console.log(_this.belt)
          }
        })
      },
      getstars() {
        var _this = this;
        this.$http.get("/static/fashion.json").then(res => {
          if (res.status === 200) {
            _this.stars = res.body.stars
            // console.log(_this.all)
          }
        })
      },
      getspecial() {
        var _this = this;
        this.$http.get("/static/fashion.json").then(res => {
          if (res.status === 200) {
            _this.special = res.body.special
            // console.log(_this.all)
          }
        })
      },
      open(id) {
        this.$router.push({path: "fashionDetail", query: {id: id}})
      },
    }
  }
</script>
